<!-- src/components/NumberKeyboard.vue -->
<template>
  <view class="keyboard">
    <view class="row">
      <button class="key" @click="onKeyPress('1')">1</button>
      <button class="key" @click="onKeyPress('2')">2</button>
      <button class="key" @click="onKeyPress('3')">3</button>
    </view>
    <view class="row">
      <button class="key" @click="onKeyPress('4')">4</button>
      <button class="key" @click="onKeyPress('5')">5</button>
      <button class="key" @click="onKeyPress('6')">6</button>
    </view>
    <view class="row">
      <button class="key" @click="onKeyPress('7')">7</button>
      <button class="key" @click="onKeyPress('8')">8</button>
      <button class="key" @click="onKeyPress('9')">9</button>
    </view>
    <view class="row">
      <button class="key" @click="onKeyPress('0')">0</button>
      <button class="key special" @click="onKeyPress('清除')">清除</button>
      <button class="key special" @click="onKeyPress('提交')">提交</button>
    </view>
  </view>
</template>

<script>
export default {
  methods: {
    onKeyPress(button) {
      this.$emit('key-press', button);
    }
  }
};
</script>

<style scoped>
.keyboard {
  background-color: #f0f0f0;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  width: 250px; /* Adjust as needed */
  margin: 0 auto; /* Center the keyboard */
}

.row {
  display: flex;
  justify-content: space-around;
  margin-bottom: 5px;
}

.key {
  padding: 12px 18px;
  border: none;
  border-radius: 8px;
  background-color: #fff;
  cursor: pointer;
  font-size: 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: background-color 0.2s ease;
  width: 30%;
  text-align: center;
}

.key:hover {
  background-color: #e0e0e0;
}

.key.special {
  background-color: #4A90E2;
  color: white;
}

.key.special:hover {
  background-color: #3A7AB9;
}
</style>